package com.google.denta.dao;

import java.util.List;

import com.google.denta.entity.PaginatorForm;
import com.google.denta.entity.User;

/**
 * @author crash
 */
/**
 * @author Aliaksei_Kuliashou
 *
 */
public interface UserDao extends Dao<User, Long> {

    /**
     * Find all users.
     * @return list of users
     */
    List<User> findAll();

    /**
     * Find (non)group's users.
     * @param gid
     *            - group id
     * @param flag
     *            - return group's (true) or non-group's (false) users
     * @return users list
     */
    List<User> findByGroup(Long gid, Boolean flag);

    /**
     * Find user by login.
     * @param name
     *            - login of user
     * @return User
     */
    User findByName(String name);

    /**
     * delete roles of user.
     * @param id
     *            - id of user
     */
    void deleteUserRoles(Long id);

    /**
     * create role for user.
     * @param uid
     *            - id of user
     * @param rid
     *            - id of role
     */
    void createUserRole(Long uid, Long rid);

    /**
     * Find user by password.
     * @param id
     *            - user id to search
     * @param password
     *            - password to search
     * @return user
     */
    User getByPassword(Long id, String password);

    /**
     * Create user group.
     * @param uid
     *            - user id
     * @param gid
     *            - group id
     */
    void createUserGroup(Long uid, Long gid);

    /**
     * Delete user groups.
     * @param id
     *            - user id
     */
    void deleteUserGroups(Long id);

    /**
     * Find operation by form.
     * @param form
     *            - operation form
     * @return list operations.
     */
    List<User> paginatorFind(PaginatorForm form);

    /**
     * Get operations count.
     * @return operation count
     */
    Long getUsersCount();

    /**
     * @param user
     * - User object with required password to update
     */
    void updatePassword(User user);

    /**
     * @param id - persone id
     * @return user, that associate with specified persone,
     * or null, if no one from users associate with specified persone
     */
    User getByPersone(Long id);

}
